function [Res_B,OutputPath]=SubFun_Solver_CPaths_BRes(PP,SS,MODEL,InputPath,Input_Lag_B,Input_Cp)

%% Setup
InputList   =   {'Pirp','Pir','dEp','dE', ...
                 'T','Profit','TAU','ir_dom','ir_ext','w'};
OutputList  =   {'B','C','L'};

VarNum_In   =   length(InputList);
VarNum_Out  =   length(OutputList);

Num_T       =   length(InputPath.Pir);
%% Input: Deviation to Levels
% Boundary Conditions
TempCp      =   MODEL.VAR.C.Dev2Level(Input_Cp);
TempLag_B   =   MODEL.VAR.Lag_B.Dev2Level(Input_Lag_B);
% Input Price Paths
for ii=1:VarNum_In
    TempVar     =   InputList{ii};
    if strcmp(TempVar,'Pirp')
        TempDev     =   zeros(size(InputPath.Pir));
        TempDev(end)=   0;
        TempDev(1:end-1)    =   InputPath.Pir(2:end);
    elseif strcmp(TempVar,'dEp')
        TempDev     =   zeros(size(InputPath.dE));
        TempDev(end)=   0;
        TempDev(1:end-1)    =   InputPath.dE(2:end);
    else
        TempDev     =   InputPath.(TempVar);
    end
    
    TempLevel   =   MODEL.VAR.(TempVar).Dev2Level(TempDev);
    eval(['Dev_',TempVar,'=TempDev;'])
    eval([TempVar,'=TempLevel;'])
end

%% Solve the Output Paths Sequentially
% Consumption
C       =   zeros(1,Num_T);
for ii=Num_T:-1:1
    C(ii)   =   ( SS.BETA*(1+ir_ext(ii))*(1+dEp(ii))/(1+Pirp(ii)) )^(-1/PP.NU_C)*TempCp;
    TempCp  =   C(ii);
end
% Labor Supply
L       =   ( C.^(-PP.NU_C).*(1-TAU).*w/SS.PSI ).^( 1/PP.NU_L );
% Saving
B       =   zeros(1,Num_T);
for ii=1:Num_T
    B(ii)       =   (1+ir_ext(ii))*( T(ii)+Profit(ii)+(1-TAU(ii))*w(ii)*L(ii) ...
                                    -C(ii)+TempLag_B*(1+dE(ii))/(1+Pir(ii)) );
    TempLag_B   =   B(ii);
end

%% Output: Levels to Deviation
OutputPath  =   struct();
for ii=1:VarNum_Out
    TempVar     =   OutputList{ii};
    eval(['TempLevel=',TempVar,';']);
    TempDev     =   MODEL.VAR.(TempVar).Level2Dev(TempLevel);
    OutputPath.(TempVar) ...
                =   TempDev;
end

Res_B       =   OutputPath.B(end);

